package com.dangdang.service.impl;

import com.dangdang.dao.OrderItemDao;
import com.dangdang.entity.OrderItem;
import com.dangdang.service.OrderItemService;
import com.dangdang.service.OrderService;
import com.dangdang.util.MyBatisUtil;
import org.apache.ibatis.session.SqlSession;

public class OrderItemServiceImpl implements OrderItemService{
    public void insert(OrderItem orderItem){
        SqlSession sqlSession = null;
        try {
            sqlSession = MyBatisUtil.getSqlSession();
            OrderItemDao dao = sqlSession.getMapper(OrderItemDao.class);
            dao.insert(orderItem);
            sqlSession.commit();
        } catch (Exception e) {
            sqlSession.rollback();
            e.printStackTrace();
            throw new RuntimeException(e);
        } finally {
            MyBatisUtil.closeSqlSession(sqlSession);
        }
    }
}
